package com.future.taskdemo.task;

import io.lettuce.core.RedisFuture;
import io.lettuce.core.api.async.RedisAsyncCommands;
import io.lettuce.core.cluster.api.async.RedisAdvancedClusterAsyncCommands;
import org.future.task.core.annotate.AutoBond;
import org.future.task.core.flow.FlowEntry;
import org.future.task.core.handler.Connection;
import org.future.task.core.handler.RunnableTask;
import org.future.task.redis.cluster.AsyncClusterAbstract;
import org.future.task.redis.cluster.AsyncClusterManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Map;


public class TaskOne extends RunnableTask<FlowEntry> {

    private Logger log = LoggerFactory.getLogger(TaskOne.class);

    @AutoBond
    private Connection defaultConnection;

    private AsyncClusterManager<String, Map<String, String>> asyncCommandManager;

    @Override
    public void execute(FlowEntry flowEntry) throws Exception {
        Object data = flowEntry.getData();
//        System.out.println(data);
//        asyncCommandManager.batchExecutorSync(new ArrayList<>(), new AsyncClusterAbstract<String, Map<String, String>>() {
//
//
//            @Override
//            public RedisFuture<Map<String, String>> command(RedisAdvancedClusterAsyncCommands<String, String> async, String row) {
//                return async.hgetall(row);
//            }
//
//            @Override
//            public void future(String row, Map<String, String> stringStringMap, Throwable throwable) {
//                if (throwable != null) {
//                    throwable.printStackTrace();
//                    return;
//                }
//                stringStringMap.put("METER_ID", row.split("\\.")[1]);
////                HandClient.cli("")
//            }
//        });
    }
}
